#include "ZipDecompressor.h"
#include <stdio.h>
#include "FileUtils.h"

void ZipDecompressor::decompress(FileHeader* fileHeader)
{
    std::string path(output_);

    path.append(fileHeader->fileName_);
    createDirectoriesFromPath(path.c_str());
    
    if(fileHeader->fileName_[fileHeader->fileNameLength_ - 1] != '/')
    {
        FILE* file = fopen(path.c_str(), "wb");
        if(file)
        {
            fwrite(fileHeader->fileData_, sizeof(char), fileHeader->unCompressedSize_, file);
            fclose(file);
        }
    }
}
